//
//  LikeCell.m
//  FreeTime
//
//  Created by  on 16/9/6.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "LikeCell.h"
#import "Header.h"

@interface LikeCell (){
    UIButton * iconBtn,*commentBtn,*likeBtn;
    UILabel * nameLbl,*timeLbl,*contentLbl;
    NSIndexPath * indexPathCell;
    NSMutableArray * imgBtnArr;
}

@end
@implementation LikeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        iconBtn = [[UIButton alloc] init];
        iconBtn.backgroundColor = DEBUG_CLOLR;
        iconBtn.tag = 202;
//        [iconBtn addTarget:self action:@selector(commentAndLikeBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:iconBtn];
        
        nameLbl = [[UILabel alloc] init];
        nameLbl.font = [UIFont boldSystemFontOfSize:14];
        nameLbl.textColor = [UIColor blackColor];
        [self addSubview:nameLbl];
        
        timeLbl = [UILabel new];
        timeLbl.font = FONT(14);
        timeLbl.textAlignment = NSTextAlignmentRight;
        timeLbl.textColor = [ImageUtil colorWithRgb:0x999999];
        [self addSubview:timeLbl];
        
       
    }
    return self;
}
- (void)bindData:(NSDictionary *)dic indexPath:(NSIndexPath *)indexPath{
    iconBtn.frame = [dic[@"iconFrame"] CGRectValue];
    nameLbl.frame = [dic[@"nameFrame"] CGRectValue];
    timeLbl.frame = [dic[@"timeFrame"] CGRectValue];
    [ToolUtil createLine:CGRectGetMaxY([dic[@"iconFrame"] CGRectValue])+14 superView:self.contentView lift:10 width:WindowWidth-20 hight:1 color:[ImageUtil colorWithRgb:0xe6e6e6]];
    [iconBtn setBackgroundImage:[UIImage imageNamed:dic[@"iconImg"]] forState:UIControlStateNormal];
    iconBtn.layer.cornerRadius = 25;
    iconBtn.layer.masksToBounds = YES;
    nameLbl.text = dic[@"name"];
    timeLbl.text = dic[@"time"];
}
+ (NSMutableDictionary *)cellFrame:(NSMutableDictionary *)dic indexPath:(NSIndexPath *)indexPath{
    dic = [LikeCell turn:dic indexPath:indexPath];
    CGRect iconFrame = CGRectMake(10, 20, 50, 50);
    CGFloat w = [ToolUtil autoWidth:dic[@"name"] width:0 height:15 num:14];
    CGRect nameFrame = CGRectMake(CGRectGetMaxX(iconFrame)+10, iconFrame.origin.y+5, w+10, 15);
    CGFloat w1 = [ToolUtil autoWidth:dic[@"time"] width:0 height:10 num:14];
    CGRect timeFrame = CGRectMake(nameFrame.origin.x,CGRectGetMaxY(nameFrame)+10, w1, 10);
    CGFloat cellHeight = CGRectGetMaxY(iconFrame)+15;

    [dic setObject:[NSValue valueWithCGRect:iconFrame] forKey:@"iconFrame"];
    [dic setObject:[NSValue valueWithCGRect:nameFrame] forKey:@"nameFrame"];
    [dic setObject:[NSValue valueWithCGRect:timeFrame] forKey:@"timeFrame"];
    [dic setObject:[NSNumber numberWithFloat:cellHeight] forKey:@"cellHeight"];
    return dic;
}

+ (NSMutableDictionary*)turn:(NSMutableDictionary*)dict indexPath:(NSIndexPath *)indexPath{
    return [NSMutableDictionary dictionaryWithDictionary:dict];
}


@end
